﻿Module Module1

    Sub Main()

        Dim sc As SimpleClass = New SimpleClass
        Dim sct As Type = sc.GetType()

        ' 可以获取到public的field
        Dim fds() As Reflection.FieldInfo = sct.GetFields()
        For Each f As Reflection.FieldInfo In fds
            Console.WriteLine(f.Name)
        Next

        Dim ps As Reflection.PropertyInfo() = sct.GetProperties()
        'Dim ps() As Reflection.PropertyInfo = sct.GetProperties()

        ' 可以不写类型
        For Each p In ps
            Console.WriteLine(p.Name)
        Next

        For Each p As Reflection.PropertyInfo In ps
            Console.WriteLine(p.Name)
        Next

        Dim arr(5) As String

        arr(0) = "a"
        arr(1) = "b"
        arr(2) = "c"
        arr(3) = "d"
        arr(4) = "e"

        For Each a In arr
            Console.WriteLine(a)
        Next

        Dim al As ArrayList = New ArrayList
        al.Add("abc")
        al.Add(2)
        al.Add(New SimpleClass)

        For Each x In al
            Console.WriteLine(x)
        Next

        Console.ReadKey()
    End Sub


    Public Class SimpleClass
        Private name As String
        Private age As Integer
        Private s As String

        ' 构造方法
        Public Sub New(name As String, age As Integer)
            Me.name = name
            Me.age = age
        End Sub

        '无参数构造方法
        Public Sub New()
        End Sub

        Public Property pname As String
            Get
                Return name
            End Get
            Set(value As String)
                Me.name = value
            End Set
        End Property

    End Class

End Module
